#include "canvass.h"
#include<QGraphicsView>
#include<QGraphicsScene>
#include<QGraphicsItem>
#include<QGraphicsEllipseItem>
#include<QGraphicsLineItem>
#include<QGraphicsPathItem>
#include<QGraphicsSceneMouseEvent>
#include<QPen>
#include<QDebug>
#include<QVector>
#include<QLabel>
#include<QGraphicsSimpleTextItem>
#include<QFont>
#include<QPushButton>

MGraph::MGraph()
{	int i,j;
    vertexNum=54;
    for(i=0;i<vertexNum;i++)
        vertex[i]=i;
    for(i=0;i<vertexNum;i++)
        for(j=0;j<vertexNum;j++)
            edge[i][j]=10000;
        edge[0][1]=1.5;
        edge[1][2]=0.9;
        edge[2][3]=1.3;
        edge[3][4]=1.4;
        edge[4][5]=0.8;

        edge[5][6]=1.2;
        edge[6][7]=1.1;
        edge[7][26]=0.8;
        edge[26][8]=1.2;
        edge[8][9]=1.1;

        edge[9][10]=1.1;
        edge[10][11]=1.5;
        edge[11][48]=1.4;
        edge[48][12]=0.9;
        edge[12][13]=3.9;

        edge[14][15]=2.2;
        edge[15][16]=7;
        edge[16][17]=4.6;
        edge[17][18]=1.6;
        edge[18][19]=6.1;

        edge[19][20]=2.2;
        edge[20][21]=2.5;
        edge[21][22]=1.6;
        edge[22][23]=1.8;
        edge[23][24]=1.8;

        edge[24][25]=1.3;
        edge[25][26]=1.1;
        edge[26][27]=1.4;
        edge[27][28]=1.3;
        edge[28][29]=3.4;

        edge[29][30]=1.4;
        edge[30][31]=1.3;
        edge[31][32]=1.6;
        edge[32][33]=1.8;
        edge[33][34]=1.6;

        edge[34][35]=2.6;
        edge[35][36]=3.8;
        edge[36][37]=2.6;

        edge[38][39]=5;
        edge[39][40]=7;
        edge[40][41]=3.9;
        edge[41][42]=5.6;
        edge[42][43]=8.7;

        edge[43][44]=5.5;
        edge[44][45]=4.9;
        edge[45][46]=2.6;
        edge[46][47]=4.8;
        edge[47][48]=3.7;

        edge[48][49]=1.3;
        edge[49][50]=0.9;
        edge[50][51]=5;
        edge[51][52]=2.2;
        edge[52][53]=6.6;
        for(i=0;i<vertexNum;i++)
        for(j=0;j<vertexNum;j++)
            {
            if(edge[j][i]!=10000)
            {
            edge[i][j]=edge[j][i];
    }}

}

 myQGV::myQGV()
{   this->setWindowFlags(Qt::FramelessWindowHint);
     setViewport(new QWidget);
    this->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
     scene->setPen();
    scene->setBackgroundBrush(Qt::white);
//    myQGEI *a[24];
//    QGraphicsSimpleTextItem *item = new QGraphicsSimpleTextItem;
//    item->setText("【【");
//    font.setPixelSize(10);
//    item->setFont(font);
//    item->setPos(225.5,500.1);
    double a[24],b[24],c[16],d[16],e[14],f[14];
    a[0]=225.4;b[0]=499.6;
    a[1]=225.4;b[1]=483.3;
    a[2]=225.4;b[2]=468.3;
    a[3]=225.4;b[3]=454.6;
    a[4]=225.4;b[4]=438.2;
    a[5]=225.4;b[5]=422.8;
    a[6]=225.4;b[6]=406.9;
    a[7]=225.4;b[7]=391.1;
    a[8]=225.4;b[8]=374.6;
    a[9]=225.4;b[9]=352.8;
    a[10]=225.4;b[10]=335.4;
    a[11]=225.4;b[11]=318.0;
    a[12]=225.4;b[12]=297.4;
    a[13]=225.4;b[13]=278.9;
    a[14]=225.4;b[14]=260.9;
    a[15]=225.4;b[15]=242.4;
    a[16]=225.4;b[16]=220.7;
    a[17]=225.4;b[17]=201.1;
    a[18]=234.4;b[18]=187.6;
    a[19]=243.4;b[19]=175.2;
    a[20]=252.4;b[20]=162.8;
    a[21]=261.4;b[21]=150.4;
    a[22]=270.4;b[22]=138.0;
    a[23]=279.6;b[23]=123.9;

    c[0]=378.2;d[0]=452.0;
    c[1]=348.2;d[1]=452.0;
    c[2]=330.6;d[2]=452.0;
    c[3]=330.6;d[3]=435.0;
    c[4]=330.6;d[4]=419.5;
    c[5]=330.6;d[5]=404.0;
    c[6]=330.6;d[6]=390.1;
    c[7]=330.6;d[7]=374.6;
    c[8]=330.6;d[8]=353.4;
    c[9]=330.6;d[9]=334.3;
    c[10]=330.6;d[10]=297.4;
    c[11]=398.3;d[11]=297.4;
    c[12]=425.7;d[12]=288.4;
    c[13]=425.7;d[13]=267.2;
    c[14]=425.7;d[14]=247.6;
    c[15]=425.7;d[15]=208.3;
    e[0]=152.6;f[0]=395.1;
    e[1]=152.6;f[1]=376.0;
    e[2]=152.6;f[2]=356.6;
    e[3]=152.6;f[3]=336.2;
    e[4]=152.6;f[4]=317.1;
    e[5]=152.6;f[5]=301.3;
    e[6]=170.0;f[6]=297.4;
    e[7]=192.1;f[7]=297.4;
   /// e[8]=225.4;f[8]=297.4;////
    e[8]=247.9;f[8]=297.4;
    e[9]=263.6;f[9]=297.4;
    e[10]=286.7;f[10]=297.4;
    e[11]=307.0;f[11]=297.4;
    //e[13]=330.6;f[13]=297.4;/////
    e[12]=392.5;f[12]=249.3;
    e[13]=330.6;f[13]=233.8;
    myQGEI *line1[14],*line2[24],*line3[16];
    for(int i=0;i<14;i++)
        line1[i]= new myQGEI(2*e[i],2*f[i],10,10);
    for(int i=0;i<24;i++)
        line2[i]= new myQGEI(2*a[i],2*b[i],10,10);
    for(int i=0;i<16;i++)
        line3[i]= new myQGEI(2*c[i],2*d[i],10,10);
    myQGLI *link1[15],*link2[24],*link3[15];

        link1[0]= new myQGLI(2*e[0]+5,2*e[1]+5,2*f[0]+5,2*f[1]+5);
        link1[1]= new myQGLI(2*e[1]+5,2*e[2]+5,2*f[1]+5,2*f[2]+5);
        link1[2]= new myQGLI(2*e[2]+5,2*e[3]+5,2*f[2]+5,2*f[3]+5);
        link1[3]= new myQGLI(2*e[3]+5,2*e[4]+5,2*f[3]+5,2*f[4]+5);
        link1[4]= new myQGLI(2*e[4]+5,2*e[5]+5,2*f[4]+5,2*f[5]+5);
        link1[5]= new myQGLI(2*e[5]+5,2*e[6]+5,2*f[5]+5,2*f[6]+5);
        link1[6]= new myQGLI(2*e[6]+5,2*e[7]+5,2*f[6]+5,2*f[7]+5);
        link1[7]= new myQGLI(2*e[7]+5,2*a[12]+5,2*f[7]+5,2*b[12]+5);
        link1[8]= new myQGLI(2*a[12]+5,2*e[8]+5,2*b[12]+5,2*f[8]+5);
        link1[9]= new myQGLI(2*e[8]+5,2*e[9]+5,2*f[8]+5,2*f[9]+5);
        link1[10]= new myQGLI(2*e[9]+5,2*e[10]+5,2*f[9]+5,2*f[10]+5);
        link1[11]= new myQGLI(2*e[10]+5,2*e[11]+5,2*f[10]+5,2*f[11]+5);
        link1[12]= new myQGLI(2*e[11]+5,2*c[10]+5,2*f[11]+5,2*d[10]+5);
        link1[13]= new myQGLI(2*c[10]+5,2*e[12]+5,2*d[10]+5,2*f[12]+5);
        link1[14]= new myQGLI(2*e[12]+5,2*e[13]+5,2*f[12]+5,2*f[13]+5);
            for(int i=0;i<23;i++)
     {   link2[i]= new myQGLI(2*a[i]+5,2*a[i+1]+5,2*b[i]+5,2*b[i+1]+5);}
    for(int i=0;i<15;i++)
      {  link3[i]= new myQGLI(2*c[i]+5,2*c[i+1]+5,2*d[i]+5,2*d[i+1]+5);}
    QColor co[3];
    co[0].setRgb(253,216,63);
    co[1].setRgb(3,108,166);
    co[2].setRgb(254,254,69);
    for(int i=0;i<14;i++)
      {pen[0].setWidth(5);
        pen[0].setColor(co[0]);
        line1[i]->setBrush(Qt::white);
        line1[i]->setPen(pen[0]);
        scene->addItem(line1[i]);
    }
        for(int i=0;i<24;i++)
          {pen[1].setWidth(5);
             pen[1].setColor(co[1]);
            line2[i]->setBrush(Qt::white);
            line2[i]->setPen(pen[1]);
        scene->addItem(line2[i]);}

        for(int i=0;i<16;i++)
              {pen[2].setWidth(5);
            pen[2].setColor(co[2]);
                line3[i]->setBrush(Qt::white);
                line3[i]->setPen(pen[2]);
                scene->addItem(line3[i]);
            }
        for(int i=0;i<15;i++)
          {pen[0].setWidth(3);
            pen[0].setStyle(Qt::DashDotLine);
            link1[i]->setPen(pen[0]);
            link1[i]->num=i;
            scene->addItem(link1[i]);
        }
        for(int i=0;i<23;i++)
          {pen[1].setWidth(3);
            pen[1].setStyle(Qt::DashDotLine);
            link2[i]->setPen(pen[1]);
            link2[i]->num=i+15;
            scene->addItem(link2[i]);
        }
        for(int i=0;i<15;i++)
          {pen[2].setWidth(3);
            pen[2].setStyle(Qt::DashDotLine);
            link3[i]->setPen(pen[2]);
            link3[i]->num=i+38;
            scene->addItem(link3[i]);
        }
            QGraphicsSimpleTextItem *simpleTextItem1[14];
        QGraphicsSimpleTextItem *simpleTextItem2[24];
        QGraphicsSimpleTextItem *simpleTextItem3[16];
        QGraphicsSimpleTextItem *simpleTextItem4[54];
        for(int i=0;i<14;i++)
            {simpleTextItem1[i]=new QGraphicsSimpleTextItem;
            simpleTextItem1[i]->setFont(QFont("Corbel",5));
            simpleTextItem1[i]->setBrush(Qt::black);}

            for(int i=0;i<24;i++)
            {simpleTextItem2[i]=new QGraphicsSimpleTextItem;
            simpleTextItem2[i]->setFont(QFont("Corbel",5));
            simpleTextItem2[i]->setBrush(Qt::black);}

            for(int i=0;i<16;i++)
            {simpleTextItem3[i]=new QGraphicsSimpleTextItem;
            simpleTextItem3[i]->setFont(QFont("Corbel",5));
            simpleTextItem3[i]->setBrush(Qt::black);}
            for(int i=0;i<53;i++)
            {simpleTextItem4[i]=new QGraphicsSimpleTextItem;
            simpleTextItem4[i]->setFont(QFont("Corbel",7));
            simpleTextItem4[i]->setBrush(Qt::black);
            scene->addItem(simpleTextItem4[i]);
            }

            simpleTextItem4[0]->setText("1.5");
            simpleTextItem4[1]->setText("0.9");
            simpleTextItem4[2]->setText("1.3");
            simpleTextItem4[3]->setText("1.4");
            simpleTextItem4[4]->setText("0.8");
            simpleTextItem4[5]->setText("1.2");
            simpleTextItem4[6]->setText("1.1");
            simpleTextItem4[7]->setText("0.8");
            simpleTextItem4[8]->setText("1.2");
            simpleTextItem4[9]->setText("1.1");
            simpleTextItem4[10]->setText("1.1");
            simpleTextItem4[11]->setText("1.5");
            simpleTextItem4[12]->setText("1.4");
            simpleTextItem4[13]->setText("0.9");
            simpleTextItem4[14]->setText("3.9");
            simpleTextItem4[15]->setText("2.2");
            simpleTextItem4[16]->setText("7");
            simpleTextItem4[17]->setText("4.6");
            simpleTextItem4[18]->setText("1.6");
            simpleTextItem4[19]->setText("6.1");
            simpleTextItem4[20]->setText("2.2");
            simpleTextItem4[21]->setText("2.5");
            simpleTextItem4[22]->setText("1.6");
            simpleTextItem4[23]->setText("1.8");
            simpleTextItem4[24]->setText("1.8");
            simpleTextItem4[25]->setText("1.3");
            simpleTextItem4[26]->setText("1.1");
            simpleTextItem4[27]->setText("1.4");
            simpleTextItem4[28]->setText("1.3");
            simpleTextItem4[29]->setText("3.4");
            simpleTextItem4[30]->setText("1.4");
            simpleTextItem4[31]->setText("1.3");
            simpleTextItem4[32]->setText("1.6");
            simpleTextItem4[33]->setText("1.8");
            simpleTextItem4[34]->setText("1.6");
            simpleTextItem4[35]->setText("2.6");
            simpleTextItem4[36]->setText("3.8");
            simpleTextItem4[37]->setText("2.6");
            simpleTextItem4[38]->setText("5");
            simpleTextItem4[39]->setText("7");
            simpleTextItem4[40]->setText("3.9");
            simpleTextItem4[41]->setText("5.6");
            simpleTextItem4[42]->setText("8.7");
            simpleTextItem4[43]->setText("5.5");
            simpleTextItem4[44]->setText("4.9");
            simpleTextItem4[45]->setText("2.6");
            simpleTextItem4[46]->setText("4.8");
            simpleTextItem4[47]->setText("3.7");
            simpleTextItem4[48]->setText("1.3");
            simpleTextItem4[49]->setText("0.9");
            simpleTextItem4[50]->setText("5.0");
            simpleTextItem4[51]->setText("2.2");
            simpleTextItem4[52]->setText("6.6");
            simpleTextItem4[0]->setPos(e[0]+e[1],f[0]+f[1]);
            simpleTextItem4[1]->setPos(e[1]+e[2],f[1]+f[2]);
            simpleTextItem4[2]->setPos(e[2]+e[3],f[2]+f[3]);
            simpleTextItem4[3]->setPos(e[3]+e[4],f[3]+f[4]);
            simpleTextItem4[4]->setPos(e[4]+e[5],f[4]+f[5]);

            simpleTextItem4[5]->setPos(e[5]+e[6],f[5]+f[6]);
            simpleTextItem4[6]->setPos(e[6]+e[7],f[6]+f[7]);
            simpleTextItem4[7]->setPos(e[7]+a[13],f[7]+b[13]);
            simpleTextItem4[8]->setPos(a[13]+e[8],b[13]+f[8]);
            simpleTextItem4[9]->setPos(e[8]+e[9],f[8]+f[9]);

            simpleTextItem4[10]->setPos(e[9]+e[10],f[9]+f[10]);
            simpleTextItem4[11]->setPos(e[10]+e[11],f[10]+f[11]);
            simpleTextItem4[12]->setPos(e[11]+c[10],f[11]+d[10]);
            simpleTextItem4[13]->setPos(c[10]+e[12],d[10]+f[12]);
            simpleTextItem4[14]->setPos(e[12]+e[13],f[12]+f[13]);
            simpleTextItem4[15]->setPos(a[0] +a[1] ,b[0] +b[1]);
            simpleTextItem4[16]->setPos(a[1] +a[2] ,b[1] +b[2]);
            simpleTextItem4[17]->setPos(a[2] +a[3] ,b[2] +b[3]);
            simpleTextItem4[18]->setPos(a[3] +a[4] ,b[3] +b[4]);
            simpleTextItem4[19]->setPos(a[4] +a[5] ,b[4] +b[5]);
            simpleTextItem4[20]->setPos(a[5] +a[6] ,b[5] +b[6]);
            simpleTextItem4[21]->setPos(a[6] +a[7] ,b[6] +b[7] );
            simpleTextItem4[22]->setPos(a[7] +a[8] ,b[7] +b[8] );
            simpleTextItem4[23]->setPos(a[8] +a[9] ,b[8] +b[9] );
            simpleTextItem4[24]->setPos(a[9] +a[10],b[9] +b[10]);
            simpleTextItem4[25]->setPos(a[10]+a[11],b[10]+b[11]);
            simpleTextItem4[26]->setPos(a[11]+a[12],b[11]+b[12]);
            simpleTextItem4[27]->setPos(a[12]+a[13],b[12]+b[13]);
            simpleTextItem4[28]->setPos(a[13]+a[14],b[13]+b[14]);
            simpleTextItem4[29]->setPos(a[14]+a[15],b[14]+b[15]);
            simpleTextItem4[30]->setPos(a[15]+a[16],b[15]+b[16]);
            simpleTextItem4[31]->setPos(a[16]+a[17],b[16]+b[17]);
            simpleTextItem4[32]->setPos(a[17]+a[18],b[17]+b[18]);
            simpleTextItem4[33]->setPos(a[18]+a[19],b[18]+b[19]);
            simpleTextItem4[34]->setPos(a[19]+a[20],b[19]+b[20]);
            simpleTextItem4[35]->setPos(a[20]+a[21],b[20]+b[21]);
            simpleTextItem4[36]->setPos(a[21]+a[22],b[21]+b[22]);
            simpleTextItem4[37]->setPos(a[22]+a[23],b[22]+b[23]);
            simpleTextItem4[38]->setPos(c[0] +c[1] ,d[0] +d[1]);
            simpleTextItem4[39]->setPos(c[1] +c[2] ,d[1] +d[2]);
            simpleTextItem4[40]->setPos(c[2] +c[3] ,d[2] +d[3]);
            simpleTextItem4[41]->setPos(c[3] +c[4] ,d[3] +d[4]);
            simpleTextItem4[42]->setPos(c[4] +c[5] ,d[4] +d[5]);
            simpleTextItem4[43]->setPos(c[5] +c[6] ,d[5] +d[6]);
            simpleTextItem4[44]->setPos(c[6] +c[7] ,d[6] +d[7]);
            simpleTextItem4[45]->setPos(c[7] +c[8] ,d[7] +d[8]);
            simpleTextItem4[46]->setPos(c[8] +c[9] ,d[8] +d[9]);
            simpleTextItem4[47]->setPos(c[9] +c[10] ,d[9] +d[10]);
            simpleTextItem4[48]->setPos(c[10]+c[11],d[10]+d[11]);
            simpleTextItem4[49]->setPos(c[11]+c[12],d[11]+d[12]);
            simpleTextItem4[50]->setPos(c[12]+c[13],d[12]+d[13]);
            simpleTextItem4[51]->setPos(c[13]+c[14],d[13]+d[14]);
            simpleTextItem4[52]->setPos(c[14]+c[15],d[14]+d[15]);
            simpleTextItem1[0]->setText("西塱");
            simpleTextItem1[0]->setPos(2*e[0]-10,2*f[0]);
            simpleTextItem1[1]->setText("坑口");
            simpleTextItem1[1]->setPos(2*e[1]-10,2*f[1]);
            simpleTextItem1[2]->setText("花地湾");
            simpleTextItem1[2]->setPos(2*e[2]-10,2*f[2]);
            simpleTextItem1[3]->setText("芳村");
            simpleTextItem1[3]->setPos(2*e[3]-10,2*f[3]);
            simpleTextItem1[4]->setText("黄沙");
            simpleTextItem1[4]->setPos(2*e[4]-10,2*f[4]);
            simpleTextItem1[5]->setText("长寿路");
            simpleTextItem1[5]->setPos(2*e[5]-10,2*f[5]);
            simpleTextItem1[6]->setText("陈家祠");
            simpleTextItem1[6]->setPos(2*e[6]-10,2*f[6]);
            simpleTextItem1[7]->setText("西门口");
            simpleTextItem1[7]->setPos(2*e[7]-10,2*f[7]);
//            simpleTextItem1[8]->setText("公元前");
//            simpleTextItem1[8]->setPos(2*e[8]-10,2*f[8]);
            simpleTextItem1[8]->setText("农讲所");
            simpleTextItem1[8]->setPos(2*e[8]-10,2*f[8]);
            simpleTextItem1[9]->setText("烈士陵园");
            simpleTextItem1[9]->setPos(2*e[9]-10,2*f[9]);
            simpleTextItem1[10]->setText("东山口");
            simpleTextItem1[10]->setPos(2*e[10]-10,2*f[10]);
            simpleTextItem1[11]->setText("杨箕");
            simpleTextItem1[11]->setPos(2*e[11]-10,2*f[11]);
//            simpleTextItem1[13]->setText("");//
//            simpleTextItem1[13]->setPos(2*e[13]-10,2*f[14]);
            simpleTextItem1[12]->setText("体育中心");
            simpleTextItem1[12]->setPos(2*e[12]-10,2*f[12]);
            simpleTextItem1[13]->setText("广州东站");
            simpleTextItem1[13]->setPos(2*e[13]-10,2*f[13]);

            simpleTextItem2[0]->setText("广州南站");
            simpleTextItem2[0]->setPos(2*a[0]-10,2*b[0]);
            simpleTextItem2[1]->setText("石壁");
            simpleTextItem2[1]->setPos(2*a[1]-10,2*b[1]);
            simpleTextItem2[2]->setText("会江");
            simpleTextItem2[2]->setPos(2*a[2]-10,2*b[2]);
            simpleTextItem2[3]->setText("南浦");
            simpleTextItem2[3]->setPos(2*a[3]-10,2*b[3]);
            simpleTextItem2[4]->setText("洛溪");
            simpleTextItem2[4]->setPos(2*a[4]-10,2*b[4]);
            simpleTextItem2[5]->setText("南洲");
            simpleTextItem2[5]->setPos(2*a[5]-10,2*b[5]);
            simpleTextItem2[6]->setText("东晓南");
            simpleTextItem2[6]->setPos(2*a[6]-10,2*b[6]);
            simpleTextItem2[7]->setText("江泰路");
            simpleTextItem2[7]->setPos(2*a[7]-10,2*b[7]);
            simpleTextItem2[8]->setText("昌岗");
            simpleTextItem2[8]->setPos(2*a[8]-10,2*b[8]);
            simpleTextItem2[9]->setText("江南西");
            simpleTextItem2[9]->setPos(2*a[9]-10,2*b[9]);
            simpleTextItem2[10]->setText("市二宫");
            simpleTextItem2[10]->setPos(2*a[10]-10,2*b[10]);
            simpleTextItem2[11]->setText("海珠广场");
            simpleTextItem2[11]->setPos(2*a[11]-10,2*b[11]);
            simpleTextItem2[12]->setText("公元前");
            simpleTextItem2[12]->setPos(2*a[12]-10,2*b[12]);
            simpleTextItem2[13]->setText("纪念堂");
            simpleTextItem2[13]->setPos(2*a[13]-10,2*b[13]);
            simpleTextItem2[14]->setText("越秀公园");
            simpleTextItem2[14]->setPos(2*a[14]-10,2*b[14]);
            simpleTextItem2[15]->setText("广州火车站");
            simpleTextItem2[15]->setPos(2*a[15]-10,2*b[15]);
            simpleTextItem2[16]->setText("三元里");
            simpleTextItem2[16]->setPos(2*a[16]-10,2*b[16]);
            simpleTextItem2[17]->setText("飞翔公园");
            simpleTextItem2[17]->setPos(2*a[17]-10,2*b[17]);
            simpleTextItem2[18]->setText("白云公园");
            simpleTextItem2[18]->setPos(2*a[18]-10,2*b[18]);
            simpleTextItem2[19]->setText("白云文化广场");
            simpleTextItem2[19]->setPos(2*a[19]-10,2*b[19]);
            simpleTextItem2[20]->setText("萧岗");
            simpleTextItem2[20]->setPos(2*a[20]-10,2*b[20]);
            simpleTextItem2[21]->setText("江夏");
            simpleTextItem2[21]->setPos(2*a[21]-10,2*b[21]);
            simpleTextItem2[22]->setText("黄边");
            simpleTextItem2[22]->setPos(2*a[22]-10,2*b[22]);
            simpleTextItem2[23]->setText("嘉禾望岗");
            simpleTextItem2[23]->setPos(2*a[23]-10,2*b[23]);
            simpleTextItem3[0]->setText("番禺广场站");
            simpleTextItem3[0]->setPos(2*c[0]-10,2*d[0]);
            simpleTextItem3[1]->setText("市桥站");
            simpleTextItem3[1]->setPos(2*c[1]-10,2*d[1]);
            simpleTextItem3[2]->setText("汉溪长隆站");
            simpleTextItem3[2]->setPos(2*c[2]-10,2*d[2]);
            simpleTextItem3[3]->setText("大石站");
            simpleTextItem3[3]->setPos(2*c[3]-10,2*d[3]);
            simpleTextItem3[4]->setText("厦滘站");
            simpleTextItem3[4]->setPos(2*c[4]-10,2*d[4]);
            simpleTextItem3[5]->setText("沥滘站");
            simpleTextItem3[5]->setPos(2*c[5]-10,2*d[5]);
            simpleTextItem3[6]->setText("大塘站");
            simpleTextItem3[6]->setPos(2*c[6]-10,2*d[6]);
            simpleTextItem3[7]->setText("客村站");
            simpleTextItem3[7]->setPos(2*c[7]-10,2*d[7]);
            simpleTextItem3[8]->setText("广州塔站");
            simpleTextItem3[8]->setPos(2*c[8]-10,2*d[8]);
            simpleTextItem3[9]->setText("珠江新城站");
            simpleTextItem3[9]->setPos(2*c[9]-10,2*d[9]);
            simpleTextItem3[10]->setText("体育西路");
            simpleTextItem3[10]->setPos(2*c[10]-10,2*d[10]);
            simpleTextItem3[11]->setText("石牌桥站");
            simpleTextItem3[11]->setPos(2*c[11]-10,2*d[11]);
            simpleTextItem3[12]->setText("岗顶站");
            simpleTextItem3[12]->setPos(2*c[12]-10,2*d[12]);
            simpleTextItem3[13]->setText("华师站");
            simpleTextItem3[13]->setPos(2*c[13]-10,2*d[13]);
            simpleTextItem3[14]->setText("五山站");
            simpleTextItem3[14]->setPos(2*c[14]-10,2*d[14]);
            simpleTextItem3[15]->setText("天河客运站");
            simpleTextItem3[15]->setPos(2*c[15]-10,2*d[15]);
        for(int i=0;i<14;i++)
        {scene->addItem(simpleTextItem1[i]);
        }
        for(int i=0;i<24;i++)
            scene->addItem(simpleTextItem2[i]);
        for(int i=0;i<16;i++)
            scene->addItem(simpleTextItem3[i]);

            resize(1920, 1080);

        for(int i=0;i<14;i++)
        {tot1[i]=e[i];tot2[i]=f[i];}
        for(int i=0;i<24;i++)
        {tot1[i+14]=a[i];tot2[i+14]=b[i];}
        for(int i=0;i<16;i++)
        {tot1[i+38]=c[i];tot2[i+38]=d[i];}
        // 定义一个视图，并把场景添加到视图

        QPushButton *aaaa=new QPushButton;
        aaaa->move(1000,1000);
        scene->addWidget(aaaa);

        edit1->setText("广州东站");

        edit2->setText("广州南站");
        ss1=edit1->text();
        ss2=edit2->text();
        edit3->setMinimumWidth(1500);
        scene->addWidget(edit1);
        scene->addWidget(edit2);
        scene->addWidget(edit3);
        scene->addWidget(edit4);
        edit1->move(900,950);
        edit2->move(900,900);
        connect(aaaa,&QPushButton::clicked,this,&myQGV::LinkLine);
scene->addItem(qig);

        setScene(scene);

}

void myQGS::setPen()
{
    circlePen.setColor(Qt::green);
    circlePen.setWidth(100);
    linePen.setWidth(100);
    linePen.setColor(Qt::yellow);


}
void myQGV::LinkLine()
{ss1=edit1->text();
    ss2=edit2->text();

    addLine(ss1,ss2);
    edit3->setText(m1->path[b1]);
}
void myQGS::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *e){
myQGEI *a= new myQGEI(e->scenePos().x(),e->scenePos().y(),100,100);
a->setPen(circlePen);
a->setBrush(Qt::green);
a->setFlags(QGraphicsItem::ItemIsMovable
                   | QGraphicsItem::ItemIsSelectable
                   | QGraphicsItem::ItemIsFocusable);

}

void myQGS::addPoint(QGraphicsSceneMouseEvent *e)
{
myQGEI *a=new myQGEI(e->pos().x(),e->pos().y(),100,100);
aa.push_back(e->pos().x());
aa.push_back(e->pos().y());
a->setBrush(Qt::green);
a->setPen(circlePen);
a->setFlags(QGraphicsItem::ItemIsMovable
                   | QGraphicsItem::ItemIsSelectable
                   | QGraphicsItem::ItemIsFocusable);
oItemGroup->addToGroup(a);

}
void myQGV::addLine(QString a,QString b)
{       if(a==olda&&b==oldb)
    {scene->removeItem(qig);
      qig=new QGraphicsItemGroup;
    return;}
    QString *total=new QString[54]{"西塱","坑口","花地湾","芳村","黄沙","长寿路","陈家祠","西门口","农讲所","烈士陵园","东山口","杨箕","体育中心","广州东站","广州南站","石壁","会江","南浦","洛溪","南洲","东晓南","江泰路","昌岗","江南西","市二宫","海珠广场","公元前","纪念堂","越秀公园","广州火车站","三元里","飞翔公园","白云公园","白云文化广场","萧岗","江夏","黄边","嘉禾望岗","番禺广场站","市桥站","汉溪长隆站","大石站","厦滘站","沥滘站","大塘站","客村站","广州塔站","珠江新城站","体育西路","石牌桥站","岗顶站","华师站","五山站","天河客运站"};
     a1=-1;b1=-1;
    for(int i=0;i<54;i++)
    {
        if(a==total[i])
      a1=i;
      if(b==total[i])
          b1=i;
    }

    if(a1==-1 ||b[1]==-1)
        return;

    m1->Dijistra(a1);

    for(int i=0;i<m1->a[b1].size()-1;i++)
       { mlin[i]=new myQGLI(2*tot1[m1->a[b1][i]]+5,2*tot1[m1->a[b1][i+1]]+5,2*tot2[m1->a[b1][i]]+5,2*tot2[m1->a[b1][i+1]]+5);
        qig->addToGroup(mlin[i]);

        QPen pen11;
        pen11.setWidth(5);
        pen11.setBrush(Qt::black);
        mlin[i]->setPen(pen11);

    }olda=a;
     oldb=b;
         QString str;
         double sum=0;
         for(int i=0;i<this->m1->a[b1].size()-1;i++)
             sum+=this->m1->edge[this->m1->a[b1][i]][this->m1->a[b1][i+1]];
         scene->addItem(qig);
             edit4->move(0,100);
             edit4->setText("公里数:"+str.setNum(sum)+"km");
}



void MGraph::Dijistra(int v)
{
    int i,k,num;
    QString *total=new QString[54]{"西塱","坑口","花地湾","芳村","黄沙","长寿路","陈家祠","西门口","农讲所","烈士陵园","东山口","杨箕","体育中心","广州东站","广州南站","石壁","会江","南浦","洛溪","南洲","东晓南","江泰路","昌岗","江南西","市二宫","海珠广场","公元前","纪念堂","越秀公园","广州火车站","三元里","飞翔公园","白云公园","白云文化广场","萧岗","江夏","黄边","嘉禾望岗","番禺广场站","市桥站","汉溪长隆站","大石站","厦滘站","沥滘站","大塘站","客村站","广州塔站","珠江新城站","体育西路","石牌桥站","岗顶站","华师站","五山站","天河客运站"};
   for(i=0;i<vertexNum;i++)
    {dist[i]=edge[v][i];
        if(dist[i]!=10000)
            {QString qs1,qs2;
            qs1.setNum(vertex[v]);qs2.setNum(vertex[i]);
            path[i]="路线： "+total[v]+" "+total[i];
            a[i].push_back(v);
            a[i].push_back(i);

            }
        else path[i]="";

    }


    for(num=1;num<vertexNum;num++)
    {
        k=Min(dist,vertexNum);


        for(i=0;i<vertexNum;i++)
    { if(dist[i]>dist[k]+edge[k][i]){
        dist[i]=dist[k]+edge[k][i];
        QString aaa;
        path[i]=path[k]+" "+total[i];
    a[i]=a[k];
            a[i].push_back(vertex[i]);

    }
    }

    dist[k]=0;
    }
}
int MGraph::Min(double a[], int vertexNum)
{	double min=10000;
    for(int i=0;i<vertexNum;i++)
    {

        if(a[i]>0&&min>a[i])
                min=a[i];}

    for(int i=0;i<vertexNum;i++)
    {
        if(min==a[i])
        return i;

    }
    for(int i=0;i<vertexNum;i++)
    {
        if(a[i]!=0)
        return i;

    }
    return -1;
}
